import useTableStore from './useTableStore'
import useEditForm from './useEditForm'

export default function useCrud(proxy, options) {
  const {
    queryModel,
    tableModel,
    upload,
    loading,
    disabled,
    resetColumnSetting,
    saveColumnSetting,
    handleSelectionChange,
    handleHeaderCellClass,
    handleSortChange,
    handleQuery,
    resetQuery,
    fetchTableData,
    pageNumChange,
    pageSizeChange,
    clickTableRow,
    handleDelete,
    handleExport,
    handleUpload,
    closeUpload,
    handleFileUploadProgress,
    handleFileSuccess,
    submitUpload
  } = useTableStore(proxy, options)

  const {
    editForm,
    handleAdd,
    handleCopyAdd,
    handleEdit,
    handleClose,
    openForm,
    resetForm,
    handleSubmit
  } = useEditForm(proxy, options)

  return {
    queryModel,
    tableModel,
    upload,
    loading,
    disabled,
    resetColumnSetting,
    saveColumnSetting,
    handleSelectionChange,
    handleHeaderCellClass,
    handleSortChange,
    handleQuery,
    resetQuery,
    fetchTableData,
    pageNumChange,
    pageSizeChange,
    clickTableRow,
    handleDelete,
    handleExport,
    handleUpload,
    closeUpload,
    handleFileUploadProgress,
    handleFileSuccess,
    submitUpload,

    editForm,
    handleAdd,
    handleCopyAdd,
    handleEdit,
    handleClose,
    openForm,
    resetForm,
    handleSubmit
  }
}
